package com.tepth.appmanageservice.protocol.bodys.system;

import com.tepth.appmanageservice.protocol.Index;
import com.tepth.appmanageservice.protocol.interfaces.IReceive;
import com.tepth.appmanageservice.tools.ext.ExtToBytes;
import com.tepth.appmanageservice.tools.ext.ExtToInt;

public class ModifyDomainPort implements IReceive {
	public static final short ID = 0x0B13;

	private String domain;
	private short port;
	int length;

	public String getDomain() {
		return this.domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}

	public short getPort() {
		return this.port;
	}

	public void setPort(short port) {
		this.port = port;
	}

	@Override
	public short getLength() {
		return 0;
	}

	@Override
	public void setLength(int length) {
		this.length = length;
	}

	@Override
	public void Receive(byte[] data, Index index) {
		this.port = ExtToInt.fromByteArrayTo16(data, index);
		int len = length - 2;
		byte[] domainBytes = ExtToBytes.fromByteArray(data, index, len);
		this.domain = new String(domainBytes);
	}
}